package com.jzoom.zoom.admin.utils;

import com.jzoom.zoom.token.hex.ClientToken;
import com.jzoom.zoom.web.action.ActionContext;

public class AdminUtils {

    public static String[] combine(String table,String[] links){
        assert (table!=null && links!=null);
        String[] rest = new String[1+links.length];
        rest[0] = table;
        for(int i=0; i < links.length; ++i){
            rest[i+1] = links[i];
        }
        return rest;
    }


    public static ClientToken getToken(ActionContext context) {
        //检查权限是否满足条件

        return context.get("token", ClientToken.class);
    }

    public static String SYSTEM = "SYSTEM";

    public static boolean isSystemUser(ClientToken token) {
        if (SYSTEM.equals(token.getRole())) {
            return true;
        }
        return false;
    }
}
